#include <iostream>
#include <vector>
using namespace std;


// version 1
int main(){
    int n = 0, q = 0;
    cin >> n >> q;

    int i = 0;
    vector<int> arr(n + 1, 0);
    for(i = 1; i <= n; ++i) cin >> arr[i];
    
    //前缀和数组
    //这里使用long long是为了防止溢出
    vector<long long> dp(n + 1, 0);
    for(i = 1; i <= n; ++i) dp[i] = dp[i - 1] + arr[i];

    //获取多行输入，每一行都是获取两个数字
    while(q--){
        int l = 0, r = 0;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    
    return 0;
}